package com.gitee.zou8944.ipersist.core

import com.alibaba.druid.pool.DruidDataSourceFactory
import com.gitee.zou8944.ipersist.core.bean.Configuration
import javax.sql.DataSource

class DefaultSqlSessionFactory(private val configuration: Configuration) : SqlSessionFactory {

    private val dataSource: DataSource = DruidDataSourceFactory.createDataSource(configuration.datasourceConfig)

    override fun openSession(): SqlSession {
        return DefaultSqlSession(dataSource.connection, configuration)
    }
}